/**
 * Copyright © 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
 */
package com.jeeplus.modules.cms.model.entity;

import com.jeeplus.cms.support.validation.PatternExtend;
import com.jeeplus.common.utils.excel.annotation.ExcelField;
import com.jeeplus.core.persistence.DataEntity;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * 模型Entity
 *
 * @author Sawyer
 * @version 2020-11-21
 */
@Getter
@Setter
@ToString
public class CmsModel extends DataEntity<CmsModel> {

    private static final long serialVersionUID = 1L;

    @Length(min = 1, max = 32, message = "模型名称长度必须介于 1 和 32 之间")
    @ExcelField(title = "模型名称", align = 2, sort = 1)
    private String name;

    @PatternExtend(regexp = "^[a-zA-Z]{1,64}$", required = true, message = "英文名称应为1-64个字符")
    @ExcelField(title = "英文名称", align = 2, sort = 2)
    private String enname;

    @PatternExtend(regexp = "^[a-zA-Z]{1,64}$", required = true, message = "数据模型应为1-64个字符")
    @ExcelField(title = "数据模型", align = 2, sort = 3)
    private String dataModel;

    @PatternExtend(regexp = "^\\w{1,64}$", message = "前端列表视图应为1-64个字符")
    @ExcelField(title = "前端列表视图", align = 2, sort = 4)
    private String frontList;

    @PatternExtend(regexp = "^\\w{1,64}$", message = "前端详情视图应为1-64个字符")
    @ExcelField(title = "前端详情视图", align = 2, sort = 5)
    private String frontForm;

    @PatternExtend(regexp = "^[0-1]$", required = true, message = "标记无效")
    @ExcelField(title = "前端分页显示标记", align = 2, sort = 6)
    private String pageFlag;

    @PatternExtend(regexp = "^[0-1]$", required = true, message = "首页显示无效")
    @ExcelField(title = "允许首页显示分类栏目标记", align = 2, sort = 7)
    private String homeFlag;

    @PatternExtend(regexp = "^[0-1]$", required = true, message = "首页推荐位标记无效")
    @ExcelField(title = "允许首页推荐位标记", align = 2, sort = 8)
    private String positionFlag;

    @PatternExtend(regexp = "^[0-1]$", required = true, message = "启用标记无效")
    @ExcelField(title = "启用标记", align = 2, sort = 9)
    private String enableFlag;

    @NotNull(message = "排序不能为空")
    @ExcelField(title = "排序", align = 2, sort = 16)
    private Integer sort;

    /**
     * 所属站点
     */
    @NotBlank(message = "所属站点不能为空")
    private String siteId;

    public CmsModel() {
        super();
        this.setIdType(IDTYPE_AUTO);
    }

    public CmsModel(String id) {
        super(id);
    }
}
